package com.ss.android.article.base.feature.update.activity;

import android.content.DialogInterface;
import android.text.TextUtils;
import android.widget.EditText;

import com.bytedance.common.utility.aa;
import com.ss.android.newmedia.a.DialogListener;

final class b implements DialogListener {
    private final a a;

    b(a arg1) {
        this.a = arg1;
    }

    public final void onCancel(DialogInterface arg1) {
    }

    public final void onDismiss(DialogInterface arg5) {
        a v1 = this.a;
        if (v1.j != 0) {
            if (v1.e != null) {
                v1.e.a();
            }

            String v0 = v1.h != null ? v1.h.getText().toString() : null;
            if (android.support.design.a.isTextEmpty(v0)) {
                return;
            }

            switch (v1.j) {
                case 1: {
                    a.a(com.bytedance.common.utility.aa.md5(String.valueOf(v1.d.b)) + "---" + v0);
                    break;
                }
                case 2: {
                    a.b(com.bytedance.common.utility.aa.md5(String.valueOf(v1.d.b)) + "---" + v0);
                    break;
                }
            }

            v1.j = 0;
        }
    }

    public final void onShow(DialogInterface arg9) {
        CharSequence v0 = null;
        a v2 = this.a;
        if (v2.h != null && v2.d != null) {
            if (!TextUtils.isEmpty(v2.d.f)) {
                v2.h.setHint(String.format(v2.c.getString(com.ss.android.article.browser.R.string.lb), v2.d.f));
            } else {
                String v3 = com.ss.android.action.bb.a().c;
                if (!android.support.design.a.isTextEmpty(v3)) {
                    v2.h.setHint(((CharSequence) v3));
                }
            }

            EditText v3_1 = v2.h;
            com.ss.android.article.base.feature.update.a.b v4 = v2.d;
            if (v4 != null) {
                switch (v2.j) {
                    case 1: {
                        long v4_1 = v4.b;
                        String v6 = a.l;
                        String v4_2 = com.bytedance.common.utility.aa.md5(String.valueOf(v4_1));
                        if (!android.support.design.a.isTextEmpty(v6) && (v6.startsWith(v4_2 + "---"))) {
                            v0 = v6.substring((v4_2 + "---").length());
                        }
                        break;
                    }
                    case 2: {
                        String v5 = a.m;
                        String v4_2 = aa.md5(String.valueOf(v4.b));
                        if (!android.support.design.a.isTextEmpty(v5) && (v5.startsWith(v4_2 + "---"))) {
                            v0 = v5.substring((v4_2 + "---").length());
                        }
                        break;
                    }
                }
            }
            v3_1.setText(v0);
        }

        v2.a();
        if (v2.h != null) {
            v2.h.requestFocus();
            int v0_2 = android.support.design.a.isTextEmpty(v2.h.getText().toString()) ? 0 : v2.h.getText().length();
            v2.h.setSelection(v0_2);
            v2.g.showSoftInput(v2.h, 0);
        }
    }
}

